function newClass(Klass, ...args) {
  const obj = {};
  obj.__proto__ = Klass.prototype;
  Klass.apply(obj, args);
  return obj;
}

function Foo(name, age) {
  this.name = name;
  this.age = age;
}

Foo.prototype.sayName = function () {
  console.log(this.name);
};

const a = newClass(Foo, 'abc', 18);
console.log(a);
a.sayName();

const b = new Foo('abc', 18);
console.log(b);
b.sayName();
